using System;
using Ninject;
using Ninject.Modules;
using Wikey.Extensibility.Interfaces;
using Wikey.Transformation.Interfaces;

namespace Wikey.Transformation
{
    public class TransformationConfiguration : Module
    {
        public TransformationConfiguration()
        {
            
        }

        public override void Load()
        {
            Bind<ITransformerRepository>().To<DictionaryTranformerRepository>();
            Bind<IExpressionEvaluator>().To<ExpressionEvaluator>();
            Bind<IExpressionParser>().To<ExpressionParser>();
            Bind<IExpressionTransformer>().To<ExpressionTransformer>().InTransientScope();
            Bind<IExpressionFunction>().To<ExpressionFunction>();
            Bind<IExpressionParameter>().To<ExpressionParameter>();

        }
    }

    public static class Factory
    {
        private static readonly IKernel kernel = new StandardKernel(new TransformationConfiguration());

        public static IKernel Kernel {
            get { return kernel; }
        }

        public static T Get<T>() {
            return kernel.Get<T>();
        }
        public static T Get<T>(Type type) {
            return (T)kernel.Get(type);
        }
        public static T TryGet<T>() {
            return kernel.TryGet<T>();
        }
        public static T TryGet<T>(Type type) {
            return (T)kernel.TryGet(type);
        }

        public static void Load(IModule module) {
            kernel.LoadModule(module);
        }
    }
}